package twelve.decorator.example;

import java.io.UnsupportedEncodingException;

public class FullBorder extends Border{
    public FullBorder(Display display) {
        super(display);
    }

    @Override
    public int getColumns() throws UnsupportedEncodingException {
        return 1 +display.getColumns() +1;
    }

    @Override
    public int getRows() {
        return 1 +display.getRows() +1;
    }

    @Override
    public String getRowText(int row) throws UnsupportedEncodingException {
        if(row == 0||row == display.getRows()+1){
            return "+" + makeLine('-',display.getColumns()) + "+";//上下边框
        }else{
            return "|" + display.getRowText(row - 1) + "|";
        }
    }
    private String makeLine(char ch,int count){
        StringBuffer buf = new StringBuffer();
        for(int i=0;i<count;i++){
            buf.append(ch);
        }
        return buf.toString();
    }
}
